<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0%;
        }

        .box1 {
            position: relative;
            display: block;
            width: 50px;
            height: 50px;
            background-color: aqua;
            margin: 100px auto;
        }

        .box1 .box2 {
            position: absolute;
            left: -10px;
            width: 10px;
            height: 10px;
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="box1">
        <div class="box2"></div>
    </div>
    <script>
        var box1 = document.querySelector('.box1');
        var box2 = document.querySelector('.box2');
        box2.onclick = function () {
                box1.style.display = 'none';
        }
    </script>
</body>

</html>